﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using YYTea.MOdel.Model;
using YYTea.ORM;
using YYTea.Services.IServices;

namespace YYTea.Services.Services
{
    public class OrderServices : IOrder
    {
        private readonly YYTeaContext _context;
        public OrderServices(YYTeaContext context)
        {
            this._context = context;
        }
        public async Task<List<Order>> GetAllOrder()
        {
            //throw new NotImplementedException();
            var allOrder = await _context.Orders.ToListAsync();
            return allOrder;
        }

        public async Task<Order> GetOrderById(Guid id)
        {

            if (id == null)
            {
                return null;
            }
            var orderById = await _context.Orders.FirstOrDefaultAsync(d => d.OrderID == id);
            return orderById;
            //throw new NotImplementedException();
        }
        
    }
}
